<?xml version="1.0" encoding="UTF-8"?>
<ui:component xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

	<ui:composition template="/pages/templates/layout_principal.xhtml">
		<ui:define name="body" width="100%">
			<h:form>
				<h:panelGrid styleClass="titulo">
					<h:outputText styleClass="titulo" value="#{menuControl.nomeProjetoSelecionado} - Lista de riscos" />
				</h:panelGrid>
				
				<br />
				
				
				
					<rich:collapsiblePanel header="Pesquisa" switchType="client">
						<table class="form_tabela">
							<tr>
								<td class="form_label">Nome risco:</td>
								<td>
									<h:inputText id="nomeRisco" name="Nome risco" value="#{manterRiscoControl.risco.nomeRisco}" />
								 	<rich:message for="nomeRisco" />
								 </td>
							</tr>
								<tr>
								<td class="form_label">Manifestado:</td>
								<td>
								
									<h:selectBooleanCheckbox value="#{manterRiscoControl.risco.manifestado}" />
								</td>
							</tr>
							<tr>
								<td class="form_label">Gravidade:</td>	
								<td>
									<h:selectOneMenu id="gravidade" value="#{manterRiscoControl.risco.gravidade}">
										<f:selectItem itemValue="" itemLabel="Todos" />
										<f:selectItems value="#{manterRiscoControl.listaGravidade}" var="gravidade" itemValue="#{gravidade}" itemLabel="#{gravidade.descricao}" />
										
									</h:selectOneMenu>
								</td>
							</tr>
						</table>
						<hr />
						<h:panelGrid columns="2" cellpadding="3" styleClass="botoes">
							<h:commandButton action="#{manterRiscoControl.pesquisarRisco()}" value="Pesquisar" styleClass="btn_principal" immediate="false" />
														
							<h:commandButton value="Novo risco" action="#{manterRiscoControl.iniciarIncluirRisco()}" />
						</h:panelGrid>

					</rich:collapsiblePanel>
				
				
			
				
				<br />
				<br />
				
				<rich:dataTable id="listaRisco"  
					var="risco"
					value="#{manterRiscoControl.listRisco}"
					rowClasses="odd-row, even-row" 
					styleClass="stable"
					rows="10" 
					columnClasses="">
					
					<f:facet name="header">
						<rich:columnGroup>
							<rich:column>Nome</rich:column>
							<rich:column>Gravidade</rich:column>
							<rich:column>Manifestado</rich:column>
							<rich:column colspan="2">Operações</rich:column>
						</rich:columnGroup>
					</f:facet>
					
					<rich:column>
						#{risco.nomeRisco}
					</rich:column>
							<rich:column>
						#{risco.gravidade}
					</rich:column>
							<rich:column>
						#{risco.manifestado}
					</rich:column>
				
					<rich:column style="width: 3%; text-align: center;">
						<h:commandLink action="#{manterRiscoControl.iniciarAlterarRisco()}">
							<f:setPropertyActionListener target="#{manterRiscoControl.risco}" value="#{risco}"/>
							<h:graphicImage library="images" name="pencil.png" title="Editar Requisito" />
						</h:commandLink>
					</rich:column>
					<rich:column style="width: 3%; text-align: center;">
						<h:commandLink action="#{manterRiscoControl.excluirRisco()}"  onclick="return confirm('Deseja realmente excluir o risco #{risco.nomeRisco}?')">
							<f:setPropertyActionListener target="#{manterRiscoControl.risco}" value="#{risco}"/>
							<h:graphicImage library="images" name="delete.png" title="Excluir Risco" />
						</h:commandLink>
					</rich:column>
								<f:facet name="footer">
							<rich:dataScroller for="listaRisco" maxPages="2" limitRender="10"
								fastControls="hide" />
						</f:facet>
				</rich:dataTable>
			</h:form>
			
			<rich:jQuery  selector=".stable tr" event="mouseover" query="jQuery(this).addClass('active-row')" />
			<rich:jQuery selector=".stable tr" event="mouseout" query="jQuery(this).removeClass('active-row')" />
		</ui:define>
		<rich:jQuery selector=".stable tr:odd" query="addClass('odd-row')" />
		<rich:jQuery selector=".stable tr:even" query="addClass('even-row')" />

	</ui:composition>

</ui:component>